@extends('layouts.default') @section('main')
<link rel="stylesheet" href="/css/uniform.css" />
<link rel="stylesheet" href="/css/select2.css" />

<div id="content">
  <div id="content-header">
    <div id="breadcrumb"> <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a> <a href="{{url('project/index')}}" class="tip-bottom">项目管理</a> <a href="{{url('project/info?id='.$project_id)}}" class="tip-bottom">项目信息</a><a href="#" class="current">项目成员管理</a> </div>
  </div>
  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span12">
      	<a href="{{url('project/membercreate?id='.$project_id)}}"><button class="btn">新增</button></a>
        <div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5>项目成员管理</h5>
          </div>
   
          <div class="widget-content nopadding">
            <table class="table table-bordered table-striped">
              <thead>
                <tr>
                  <th>成员ID</th>
                  <th>成员名</th>
                  <th>成员职位</th>
                  <th>成员身份</th>
                  <th>创建时间</th>
                  <th>状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              	@foreach($members as $key => $member)
                <tr class="gradeX">
                  <td>{{ $member->id }}</td>
                  <td>{{ $member->name }}</td>
                  <td>{{ $member->position }}</td>
                  <td>@if($member->is_leader)领导@else普通@endif</td>
                  <td><?php echo date('Y-m-d',strtotime($member->created_at)); ?></td>
                  <td>@if($member->status == 1)正常@else禁用@endif</td>
                  <td class="center"> 
	                  <a data-original-title="编辑" id="edit" class="tip" href="{{url('/project/memberedit?id='.$member->id)}}"><i class="icon-pencil"></i></a>
	                  <a data-original-title="删除" id="delete"  data-toggle="modal" class="tip member_delete" m_id="{{$member->id}}" href="#myAlert"><i class="icon-remove"></i></a>
                  </td>
                </tr>
                @endforeach
              </tbody>
            </table>
          </div>
        </div><?php echo $members->render();?>
      </div>
    </div>
  </div>
</div>

<div>
    <div id="myAlert" class="modal hide">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h3>提示</h3>
        </div>
        <div class="modal-body">
            <p>确认删除这条数据吗？</p>
        </div>
        <div class="modal-footer">
            <a data-dismiss="modal" class="btn btn-primary" href="javascript:void(0);">确定</a>
            <a data-dismiss="modal" class="btn" href="javascript:void(0);">取消</a>
        </div>
    </div>
    <form action="{{url('project/memberdelete')}}" method="post" id="adForm">
        <input type="hidden" name="mid" value="0">
    </form>
</div>

<script src="/js/matrix.tables.js"></script>
<script src="/js/common.js"></script>

<script>

    $(".member_delete").click(function(){
        var m_id = $(this).attr("m_id");
        $("input[name='mid']").val(m_id);
    });
    $(".btn-primary").click(function(){
        var m_id = $("input[name='mid']").val();
        if(m_id == 0){
            alert('参数异常');
            return;
        }

        ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
            if(data.status){
                alert(data.message);
                window.location.href = data.forwardUrl;
            }else{
                alert(data.message);
            }
        });
    });
    
</script>
@stop
